import java.util.ArrayList;
import java.util.HashMap;

import hr.irb.random.*;


public class main {
	private String TYPE="American";
	private static int LIMIT=6000;
	private static int wallet;
	private static int betafter=3;
	
	public static void main(String[] args) {
		HashMap<Integer,Slot> rouletteTable= new HashMap<Integer,Slot>();
		ArrayList<Slot>history=new ArrayList<Slot>();
		wallet=100;
		
		for(int i=0;i<=36;i++){
			rouletteTable.put(i,new Slot(i));
		}
		int spin=0;
		int pick;
		int IRW=1;
		boolean bet=false;
		boolean won=false;
		String betcolor="nothing";
		Slot previousSlot;
		Slot currentSlot=rouletteTable.get(0);
		while(spin<LIMIT){
			//System.out.println("Spin: "+spin+ " won "+won+" bet "+bet+" IRW "+IRW);
			pick=(int) (Math.random()*36);
			previousSlot=currentSlot;
			currentSlot=rouletteTable.get(pick);
			System.out.print(spin+" ");
			if(currentSlot.getColor().equals("red"))System.out.println("RED");
			else if(currentSlot.getColor().equals("black"))System.out.println("BLACK");
			else System.out.println("GREEN");
			if(bet){
				if(currentSlot.getColor().equals(betcolor)){
					wallet+=20;
					won=true;
					bet=false;
					betcolor="nothing";
					System.out.println("WON 20 NOW AT "+wallet+"$");
				}
				else{
					wallet-=10;
					won=false;
					bet=false;
					betcolor="nothing";
					System.out.println("LOST 10 NOW AT "+wallet+"$");
				}
			}
			//System.out.println("Spin "+spin+": "+currentSlot.getNumber()+" "+currentSlot.getColor()+" Wallet: "+wallet);
			
			won=false;
			spin++;
			history.add(currentSlot);
			if(previousSlot.getColor().equals(currentSlot.getColor())){
				IRW++;	
			}else{
				IRW=1;	
			}
			
			if(IRW>=betafter&&!won){
				bet=true;
				if(currentSlot.getColor().equals("black"))betcolor="red";
				else betcolor="black";
			}
			
		}

	}

}

